package com.example.administrator.myapplication;

        import android.content.Intent;
        import android.os.Bundle;
        import android.support.annotation.Nullable;
        import android.support.v7.app.AppCompatActivity;
        import android.view.View;
        import android.widget.Button;
        import android.widget.EditText;
        import android.widget.Toast;

/**
 * Created by Administrator on 2020/11/19.
 */

public class MainActivity extends AppCompatActivity {

    private Button btn;
    private EditText et1;
    private EditText et2;
    private EditText et3;
    private Button btn1;
    private String name;
    private String cj;
    private String jg;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initEvent();
    }

    private void initView() {
        btn = findViewById(R.id.btn);
        et1 = findViewById(R.id.et1);
        et2 = findViewById(R.id.et2);
        et3 = findViewById(R.id.et3);
        btn1 = findViewById(R.id.btn1);


    }

    private void initData() {

        name = et1.getText().toString() + "";
        cj = et2.getText().toString() + "";
        jg = et3.getText().toString() + "";


    }

    private void initEvent() {
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();//关闭当前页面
            }
        });
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                initData();
                int score = Integer.parseInt(cj);
                boolean ispassed = Boolean.parseBoolean(jg);
                Intent intent = new Intent(MainActivity.this, Main2Activity.class);
//                intent.putExtra("name", name);
//                intent.putExtra("score",score);
//                intent.putExtra("ispassed",ispassed);
                //实例化bundle
                Bundle bundle = new Bundle();

                bundle.putString("name",name);
                bundle.putInt("score",score);
                bundle.putBoolean("ispassed",ispassed);
                intent.putExtras(bundle);
                Toast.makeText(MainActivity.this, "" + name, Toast.LENGTH_SHORT).show();
                startActivity(intent);
            }
        });
    }
}